package luceneqe.modelsIR.clauses;

import java.io.IOException;
import java.util.Set;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.Searcher;
import org.apache.lucene.search.Similarity;
import org.apache.lucene.search.Weight;

@SuppressWarnings("serial")
public class BM25MultiClauseQuery extends Query {

	
	public enum BooleanQuery {
	    AND,OR 
	}
	private Query query;	
	String[] fields;
	private BooleanQuery queryType = BooleanQuery.OR;
	private String boostedQuery;
	

	public BM25MultiClauseQuery(Query query, String[] fields,BooleanQuery queryType, String boostedQuery) {
		this.query = query;	
		this.fields = fields;
		this.queryType = queryType;
		this.boostedQuery = boostedQuery;
	}
	
	public BM25MultiClauseQuery(Query query, String[] fields, String boostedQuery) {
		this.query = query;	
		this.fields = fields;
		this.boostedQuery = boostedQuery;
	}

	@Override
	public Object clone() {
		return super.clone();
	}

	@Override
	public Query combine(Query[] queries) {
		System.out.println("COMBINE");
		return super.combine(queries);
	}

	@Override
	protected Weight createWeight(Searcher searcher) throws IOException {
		Weight weight = super.createWeight(searcher);
		System.out.println(weight.getClass().getName());
		return weight;
	}

	@SuppressWarnings("unchecked")
	@Override
	public void extractTerms(Set terms) {
		super.extractTerms(terms);
	}

	@Override
	public float getBoost() {
		return super.getBoost();
	}

	@Override
	public Similarity getSimilarity(Searcher searcher) {
		return super.getSimilarity(searcher);
	}

	@Override
	public Query rewrite(IndexReader reader) throws IOException {
		System.out.println("REWRITE");
		return super.rewrite(reader);
	}

	@Override
	public void setBoost(float b) {
		super.setBoost(b);
	}

	@Override
	public String toString() {
		return super.toString();
	}

	@Override
	public Weight weight(Searcher searcher) throws IOException {
		Weight weight = new BM25MultiClauseWeight(this.query,searcher,this.fields,this.queryType, this.boostedQuery);		
		return weight;

	}

	@Override
	public String toString(String field) {
		// TODO Auto-generated method stub
		return null;
	}

}